/*
 * addon_dllutil.h
 *
 *  Created on: 2010-1-7
 *      Author: gavinkwoe
 */

#ifndef ADDON_DLLUTIL_H_
#define ADDON_DLLUTIL_H_

#include "addon_features.h"
#include "addon_std.h"
#include "addon_objbase.h"

/*************************************************************************
* INTERFACE
*************************************************************************/

ADDON_INTERFACE_( IAddonDLL, 1, IObject )
{
	__INHERIT_FROM( IObject )

	ADDON_METHOD( IsLoaded )	( ADDON_REF(IObject) thiz, OUT unsigned long * is_load );
	ADDON_METHOD( Load )		( ADDON_REF(IObject) thiz, IN unsigned short * fname );
	ADDON_METHOD( Unload )		( ADDON_REF(IObject) thiz );
	ADDON_METHOD( GetProcAddr )	( ADDON_REF(IObject) thiz, IN unsigned long index, OUT void ** ppaddr );
};

/*************************************************************************
* DECLARATION
*************************************************************************/

#if defined(__cplusplus)
extern "C" {
#endif	// #if defined(__cplusplus)
	
ADDON_IMPORT ADDON_REF(IObject)	addon_create_DLL( void * reserved );

#if defined(__cplusplus)
};
#endif	// #if defined(__cplusplus)

/*************************************************************************
* MACRO
*************************************************************************/

#define IAddonDLL_VTBL( p )					ADDON_GET_VTBL_(p, IAddonDLL)
#define IAddonDLL_CALL( p, a )				IAddonDLL_VTBL(p)->a
#define IAddonDLL_IsLoaded( p, a )			IAddonDLL_CALL( p, IsLoaded )( p, a )
#define IAddonDLL_Load( p, a )				IAddonDLL_CALL( p, Load )( p, a )
#define IAddonDLL_Unload( p )				IAddonDLL_CALL( p, Unload )( p )
#define IAddonDLL_GetProcAddr( p, a, b )	IAddonDLL_CALL( p, GetProcAddr )( p, a, b )

#endif /* ADDON_DLLUTIL_H_ */
